import api from "../request/request"

// 小程序的openid
export const getOpenId = (obj) => {
  const data = api({
    url: `secondTrialLogin?code=${obj.code}`,
    method: 'GET'
  })
  return data
}
// 公众号的openid
export const getServiceOfficialAccountOpenid = (obj) => {
  const data = api({
    url: `sofficialAccount?code=${obj.code}`,
    method: 'GET'
  })
  return data
}
// 通过access_token获取openid
export const getServiceOfficialAccountOpenidAccess = (obj) => {
  const data = api({
    url: `sofficialAccountAccessOpenid`,
    method: 'GET'
  })
  return data
}
// 获取当前用户信息
export const getUserInfo = (obj) => {
  const data = api({
    url: `filing/v1/api/userInfo?userId=${obj.userId}&wechatUnionId=${obj.wechatUnionId}&wechatServiceOfficialAccountOpenId=${obj.wechatServiceOfficialAccountOpenId}&wechatMiniprogramOpenId=${obj.wechatMiniprogramOpenId}`,
    method: 'GET'
  })
  return data
}
// 获取用户协议
export const getUserAgree = (obj) => {
  const data = api({
    url: `filing/v1/api/agreement?version=${obj.version}`,
    method: "GET"
  })
  return data
}

// 签署协议
export const signAgreement = (obj) => {
  const data = api({
    url: 'filing/v1/api/agreement/sign',
    method: 'POST',
    data: obj
  })
  return data
}

// 创建微信用户
export const createWechat = (obj) => {
  const data = api({
    url: 'filing/v1/api/userInfo/wechat',
    method: 'POST',
    data: obj
  })
  return data
}
// 获取用户微信信息
export const getWechat = (obj) => {
  const data = api({
    url: `filing/v1/api/userInfo/wechat?familyMemberId=${obj.familyMemberId}`,
    method: 'GET'
  })
  return data
}

// 推送服务消息
export const pushMessage = (obj) => {
  const data = api({
    url: `serviceMessagepush?openId=${obj.openId}`,
    method: 'GET'
  })
  return data
}